﻿<MudTable T="string" Items="_items" OnRowMouseEnter="@(args => OnRowMouseEnter(args))" OnRowMouseLeave="@(args => OnRowMouseLeave(args))">
    <RowTemplate>
        <MudTd>@context</MudTd>
    </RowTemplate>
</MudTable>

<p>
    Current: '@(_currentlyHoveredItem)', last: '@(_lastHoveredItem)'
</p>

@code {
    public static string __description__ = @"
                                                   OnRowMouseEnter should be called whenever a row (<tr>) starts being hovered (onpointerenter).
                                                   OnRowMouseLeave should be called whenever a row (<tr>) stops being hovered (onpointerleave).
                                                   The paragraph (<p>) should be refreshed with the current and last hovered element.
                                           ";

    private readonly string[] _items = ["A", "B"];
    private string? _lastHoveredItem = string.Empty;
    private string? _currentlyHoveredItem = string.Empty;

    private void OnRowMouseEnter(TableRowHoverEventArgs<string> args)
    {
        _currentlyHoveredItem = args.Item;
    }

    private void OnRowMouseLeave(TableRowHoverEventArgs<string> args)
    {
        _currentlyHoveredItem = string.Empty;
        _lastHoveredItem = args.Item;
    }
}
